set(ExeName RPS)
set(ProfileDir ${SDK_DIR}/dwThreadPool/external/Remotery/lib)
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/Common
    ${OSG_DIR}/include
    ${SDK_DIR}/rapidjson/include
    ${SDK_DIR}/dwThreadPool/include
    ${SDK_DIR}/entt/src/entt
    ${ProfileDir}
)

file(GLOB rapidjsonFiles ${SDK_DIR}/rapidjson/include/rapidjson/*.h)
source_group(rapidjson FILES ${rapidjsonFiles})

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
    link_directories(${OSG_DIR}/debug/lib)
    set(LIBS 
        osgd 
        osgViewerd 
        osgUtild 
        osgDBd 
        osgGAd
        osgTextd
    )
    set(ThreadLib 
        OpenThreadsd
    )
    set(DLLS 
        osgd.dll 
        osgViewerd.dll 
        osgUtild.dll 
        osgDBd.dll 
        osgGAd.dll
        osgTextd.dll
    )
    set(OSG_BIN_DIR ${OSG_DIR}/debug/bin)
else()
    link_directories(${OSG_DIR}/release/lib)
    set(LIBS 
        osg 
        osgViewer 
        osgUtil 
        osgDB 
        osgGA
        osgText
    )
    set(ThreadLib 
        OpenThreads
    )
    set(DLLS 
        osg.dll 
        osgViewer.dll 
        osgUtil.dll 
        osgDB.dll 
        osgGA.dll
        osgText.dll
    )
    set(OSG_BIN_DIR ${OSG_DIR}/release/bin)
endif()



add_executable(${ExeName} 
    main.cpp
    ICETask.cpp
    ${ProfileDir}/Remotery.c
    #${rapidjsonFiles}
)
target_link_libraries(${ExeName} ${LIBS} ${ThreadLib} opengl32.lib)


foreach(dll ${DLLS})
    add_custom_command(TARGET ${ExeName}
        POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy ${OSG_BIN_DIR}/osg158-${dll} ${EXECUTABLE_OUTPUT_PATH}
    )
endforeach(dll)

foreach(pdb ${LIBS})
    add_custom_command(TARGET ${ExeName}
        POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy ${OSG_BIN_DIR}/osg158-${pdb}.pdb ${EXECUTABLE_OUTPUT_PATH}
    )
endforeach(pdb)

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
    add_custom_command(TARGET ${ExeName}
        POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy ${OSG_BIN_DIR}/ot21-OpenThreadsd.dll ${EXECUTABLE_OUTPUT_PATH}
        COMMAND ${CMAKE_COMMAND} -E copy ${OSG_BIN_DIR}/ot21-OpenThreadsd.pdb ${EXECUTABLE_OUTPUT_PATH}
    )
else()
    add_custom_command(TARGET ${ExeName}
        POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy ${OSG_BIN_DIR}/ot21-OpenThreads.dll ${EXECUTABLE_OUTPUT_PATH}
    )
endif()